using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using BUS;
using Utility;
namespace BUS
{
    public class tbHinhAnhBUS
    {
        public static void Insert(tbHinhAnh hinhanh)
        {
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            hinhanhDAL.Insert(hinhanh);
        }
        public static void Update(tbHinhAnh hinhanh)
        {
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            hinhanhDAL.Update(hinhanh);
        }

        public static void Detele(int iD)
        {
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            hinhanhDAL.Delete(iD);
        }
        public static void DeleteIdSP(int IdSanPham)
        {
            tbHinhAnhDAL hinhAnhDAL = new tbHinhAnhDAL();
            hinhAnhDAL.DeleteIdSP (IdSanPham);
        }
        public static string [] DeleteImageByIdSP(int IdSanPham)
        {
            tbHinhAnhDAL hinhAnhDAL = new tbHinhAnhDAL();
            return hinhAnhDAL.DeleteImageByIdSP(IdSanPham);
        }
        public static tbHinhAnhCollection Get(string where, int pageIndex, int pageSize, string orderBy, string orderDirection, out int total)
        {
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            return hinhanhDAL.Get(where, pageIndex, pageSize, orderBy, orderDirection, out total);
        }

        public static tbHinhAnhCollection GetAll()
        {
            int total = 0;
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            return hinhanhDAL.Get("where 1=1", 0, 0, tbHinhAnhColumns.IdHinhAnh.ToString(), OrderDirection .ASC .ToString (), out total);
        }

        public static tbHinhAnh GetById(int iD)
        {
            int total = 0;
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            Criteria Cri = new Criteria();
            Cri.add(Condition.AND, tbHinhAnhColumns.IdHinhAnh.ToString(), Condition.EQUAL, iD);
            tbHinhAnhCollection hinhanhCollection = hinhanhDAL.Get(Cri .Criter ,0,0,tbHinhAnhColumns .IdHinhAnh .ToString (),
                                                    OrderDirection .ASC .ToString (),out total );
            if (hinhanhCollection.Count > 0)
                return hinhanhCollection[0];
            return null;
        }
        public static int FirstImage(int IdSanPham,int Id)
        {
            tbHinhAnhDAL hinhAnhDAL = new tbHinhAnhDAL();
            return hinhAnhDAL.FirstImage(IdSanPham, Id);
        }
        
     
    }
}
